﻿using STHPMS1.DAL.D_Core;
using STHPMS1.ICore.I_DAL.Repository;
using STHPMS1.ICore.I_Entity.Stmpms1;
using System.Collections.Generic;
using System.Data;
using ServiceStack.OrmLite;
using System.Text;
using System.Data.SqlClient;
using System;

namespace STHPMS1.DAL.D_Repository
{
    public class Dn_Traffic_WayRepository : DalBase, IDn_Traffic_WayRepository
    {
        /// <summary>
        /// 返回该路段的交通量的年份分组情况
        /// </summary>
        /// <param name="rdwaryId"></param>
        /// <returns></returns>
        public List<string> GetYear(IB_Invntory b)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string sql = string.Format(@"select year(obvtm) from S_TRFVOLSURVEY a inner join S_APPLY b
on a.APPLYID = b.APPLYID where APPRDID='{0}'and DIRECTION_DICTID={1}
and (APPBEGINMP<= {2} and APPENDMP>={3})group by year(obvtm)", b.Rdwayid,b.Direction_Dictid,b.Beginmp,b.Endmp);
           
            return conn.Select<string>(sql);
        } 

        public void Update(IDn_Traffic_Way entity)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string sql = string.Format(@"update Dn_Traffic_Way set Easl={0},Svydata='{1}',Rl={2} where segid='{3}'",entity.Easl,entity.Svydata,entity.Rl,entity.Segid);
            conn.ExecuteNonQuery(sql);
        }
    }
}
